﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            string password = TextBox2.Text;
            int gender = RadioButton1.Checked ? 0 : 1;
            string email = TextBox3.Text;

            string sql = "insert into StuInfo(Name , Password , Sex , Email) values (@name , @password , @gender , @email)";
            SqlParameter[] pars =
            {
                new SqlParameter("@name",name),
                new SqlParameter("@password",password),
                new SqlParameter("@gender",gender),
                new SqlParameter("@email",email),
            };
            SQLHelper Helper = new SQLHelper();
            int result = Helper.Execute(sql, pars);
            if (result == 1)
            {
                Literal1.Text = "注册成功!<a href = \"Login.aspx\">点击登录</a>";
            }
        }
    }
}